package com.situ.boot.config;

import com.situ.boot.entity.AdminUserEntity;
import com.situ.boot.entity.User;
import com.situ.boot.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// @Configuration用于定义配置类，可替代xml配置文件，被注解的类内部包含有一个或多个被@Bean注解的方法
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    @Bean
    public AdminUserEntity getUser() {
        AdminUserEntity user = new AdminUserEntity();
        return  user;
    }

    // 用这个方法来注册拦截器，我们写的拦截器需要在这里配置才能生效
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns("/**") 表示拦截所有的请求
        // excludePathPatterns ：代表那些请求不需要进行拦截
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login", "/user/getLoginPage","/static/common/mylayer.js","/static/lib/layui/layui.js","/static/back/js/jquery.min.js");
    }
}
